<a href="#comments"></a>
<ul id='comments' class="comment">
	<%#= render :partial=>"comments/object", :collection=>record.comments %>
	<% if logged_in? %>
			<%= form_tag comment_path(:id=>0), :method=>:put %>
				<%= hidden_field_tag "referrer", @template.request.url %>
				<%= hidden_field_tag "model", record.id %>
				<%= hidden_field_tag "comment_action", 0 %>
				<%= select_tag "select_action", options_for_select([ ["Выбрать действие", 0],  ["Скрыть", 1], ["Удалить", 2]]), {:style=>"width:150px;", :onchange=>"if(confirm('Вы уверены?')){$('comment_action').value=this.value;this.form.submit();}else{this.value=0}"} %>
				
				<%#= display_comments( (logged_in? && (current_user.admin? || record.user == current_user) ? comments : comments.visible)) %>
				<%= display_comments(comments) %>
				
				<div style="padding-top:30px;"><%= select_tag "select_action", options_for_select([ ["Выбрать действие", 0],  ["Скрыть", 1], ["Удалить", 2]]), {:style=>"width:150px;", :onchange=>"if(confirm('Вы уверены?')){$('comment_action').value=this.value;this.form.submit();}else{this.value=0}"} %></div>
			</form>
	<% else %>
		<%= display_comments(comments) %>
	<% end %>
</ul>

<script language="javascript">
	function show_comments(comment_id)
	{
		var show_li = $('show_comment_' + comment_id.toString());
		var comment_li = $('comment_' + comment_id.toString());
		
		if (comment_li.visible()){
			comment_li.hide();
			show_li.update("<a href='#' onclick='show_comments(" + comment_id.toString() + ");return false;'>показать комменты...</a>");
		} else {
			comment_li.show();
			show_li.update("<a href='#' onclick='show_comments(" + comment_id.toString() + ");return false;'>скрыть комменты...</a>");
		}
	}
</script>
